package com.me.chat.util;

import org.springframework.beans.BeanUtils;

/**
 * 通用操作类
 * @Authhor: qiu
 * @Date: 2021/12/8 12:32 下午
 */

public class CommonUtil {

    /**
     * 对象复制
     * @param object
     * @param clazz
     * @param <T>
     * @return
     */
    public static<T> T copyObject(Object object, Class<T> clazz) {
        T t = null;
        try {
            t = clazz.newInstance();
            BeanUtils.copyProperties(object,t,clazz);
        } catch (InstantiationException e) {
            e.printStackTrace();
            return null;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            return null;
        }
        return t;
    }
}
